home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / gfx / pbm / hpcd2ppm_0_5_pl1.lha / hpcdtoppm.0.5.pl1 / src / hpcdtoppm.h < prev    next >
C/C++ Source or Header  |  1993-08-20  |  5KB  |  208 lines

  1. /* hpcdtoppm (Hadmut's pcdtoppm) v0.5pl1
  2. *  Copyright (c) 1992, 1993 by Hadmut Danisch (danisch@ira.uka.de).
  3. *  Permission to use and distribute this software and its
  4. *  documentation for noncommercial use and without fee is hereby granted,
  5. *  provided that the above copyright notice appear in all copies and that
  6. *  both that copyright notice and this permission notice appear in
  7. *  supporting documentation. It is not allowed to sell this software in
  8. *  any way. This software is not public domain.
  9. */
  10.  
  11.  
  12. #include <stdio.h>
  13. #include <string.h>
  14. #ifdef __STDC__
  15. #include <stdlib.h>
  16. #else
  17. #include <malloc.h>
  18. #endif
  19. #include <sys/types.h>
  20. #include <ctype.h>
  21. #include "config.h"
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. /* Format definitions */
  31.  
  32. #define BaseW ((dim)768)
  33. #define BaseH ((dim)512)
  34.  
  35. #define SECSIZE 0x800
  36.  
  37. #define SeHead   2
  38. #define L_Head   (1+SeHead)
  39.  
  40. #define SeBase16 18
  41. #define L_Base16 (1+SeBase16)
  42.  
  43. #define SeBase4  72
  44. #define L_Base4  (1+SeBase4)
  45.  
  46. #define SeBase   288
  47. #define L_Base   (1+SeBase)
  48.  
  49.  
  50. #define neutrLum 128
  51. #define neutrCh1 156
  52. #define neutrCh2 137
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. /* Structures and definitions */
  61. struct _implane
  62.  {dim  mwidth,mheight,
  63.        iwidth,iheight;
  64.   uBYTE *im,*mp;
  65.  };
  66. typedef struct _implane implane;
  67.  
  68. #define nullplane ((implane *) 0)
  69.  
  70.  
  71.  
  72.  
  73.  
  74. struct _sizeinfo
  75.  {dim w,h;  /* Image Resolution */
  76.   dim rdhoff,rdhlen, rdvoff, rdvlen; /* Size of Image in Memory */
  77.   dim imhoff,imhlen, imvoff, imvlen; /* Real Size of Image */
  78.  };
  79. typedef struct _sizeinfo sizeinfo;
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. enum   TURNS  { T_UNSPEC,T_NONE,T_RIGHT,T_LEFT,T_HEAD,T_AUTO };
  87. enum   SIZES  { S_UNSPEC,S_Base16,S_Base4,S_Base,S_4Base,S_16Base,S_Over,S_Contact };
  88. enum   OUTFOR { O_UNSPEC,O_PPM,O_PGM,O_YCC,O_PS,O_EPS,O_PSG,O_EPSG,O_PSD,O_EPSD };
  89. enum   CORR   { C_UNSPEC,C_LINEAR,C_DARK,C_BRIGHT };
  90.  
  91. enum   ERRORS { E_NONE,E_READ,E_WRITE,E_INTERN,E_ARG,E_OPT,E_MEM,E_HUFF,
  92.                 E_SEQ,E_SEQ1,E_SEQ2,E_SEQ3,E_SEQ4,E_SEQ5,E_SEQ6,E_SEQ7,E_POS,E_IMP,E_OVSKIP,
  93.                 E_TAUTO,E_TCANT,E_SUBR,E_PRPAR,E_CONFIG };
  94.  
  95.  
  96.  
  97.  
  98.  
  99. /**** Macros ****/
  100.  
  101.  
  102.  
  103. #ifdef DEBUG
  104. #define RPRINT  {fprintf(stderr,"R-Position %x\n",bufpos);}
  105. #else
  106. #define RPRINT
  107. #endif
  108.  
  109. #define melde(x) {if (do_melde) fprintf(stderr,x);}
  110.  
  111.  
  112. #define READBUF   READ(sbuffer,sizeof(sbuffer))
  113. #define EREADBUF {if(READBUF < 1) error(E_READ);}
  114.  
  115. #define SKIP(p)  { if (SKIPn(p)) error(E_READ);}
  116. #define SKIPr(p) { if (SKIPn(p)) return(E_READ);}
  117.  
  118.  
  119. #define TRIF(x,u,o,a,b,c) ((x)<(u)? (a) : ( (x)>(o)?(c):(b)  ))
  120. #define xNORM(x) x=TRIF(x,0,255,0,x,255)
  121. #define NORM(x) { if(x<0) x=0; else if (x>255) x=255;}
  122.  
  123. #ifndef MIN
  124. #define MIN(a,b) (((a) < (b)) ? (a) : (b))
  125. #endif
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. /* main.c */
  135. extern void         close_all(void);
  136.  
  137. extern char         *ppmname,*pcdname;
  138. extern sINT         do_diff,do_info,do_sharp,do_overskip,monochrome;
  139. extern sINT         do_melde,do_rep,do_crop;
  140. extern sINT         flvert,flhori;
  141. extern uBYTE        sbuffer[SECSIZE];
  142. extern enum TURNS   turn;
  143. extern enum SIZES   size;
  144. extern enum OUTFOR  outfor;
  145. extern enum CORR    corrmode;
  146.  
  147. extern void         SEEK(int);
  148. extern int          SKIPn(int);
  149. extern int          READ(uBYTE *,int);
  150. extern sINT         bufpos;
  151.  
  152.  
  153.  
  154.  
  155. /* error.c */
  156. extern void         eerror(enum ERRORS,char *, int);
  157.  
  158.  
  159. /* color.c */
  160. extern void         colconvert(sizeinfo *,implane *,implane *,implane *);
  161.  
  162. /* tools.c */
  163. extern void         clearimpl(implane *,sINT);
  164. extern void         halve(implane *);
  165. extern void         interpolate(implane *);
  166. extern sINT         Skip4Base(void);
  167. extern void         planealloc(implane *,dim,dim);
  168. extern void         pastein(implane *,dim,dim,dim,dim,implane *, enum TURNS);
  169. extern void         cropit(sizeinfo *,implane *,implane *,implane *);
  170. extern void         shrink(sizeinfo *,implane *,implane *,implane *);
  171. extern void         typecheck(void);
  172.  
  173.  
  174. /* format.c */
  175. extern void         readhqt(sINT);
  176. extern void         decode(sizeinfo *,int,implane *,implane *,implane *,sINT);
  177. extern enum ERRORS  readplain(sizeinfo *,int,implane *,implane *,implane *);
  178.  
  179.  
  180.  
  181.  
  182.  
  183. /* Type definitions for output format drives, used in output.c and the drivers */
  184.  
  185. typedef void (*OUT1PL)(FILE *,dim,dim, uBYTE *,sdim,sdim);
  186. typedef void (*OUT3PL)(FILE *,dim,dim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim);
  187.  
  188. /* output.c */
  189. extern void         writepicture(FILE *,sizeinfo *,implane *,implane *,implane *,enum TURNS);
  190. extern void         druckeid(void);
  191.  
  192.  
  193. /* ppm.c */
  194. extern void write_ppm(FILE *,dim,dim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim);
  195. extern void write_pgm(FILE *,dim,dim, uBYTE *,sdim,sdim);
  196.  
  197. /* postscr.c */
  198. extern void write_epsrgb(FILE *,dim,dim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim);
  199. extern void write_psrgb(FILE *,dim,dim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim);
  200. extern void write_epsgrey(FILE *,dim,dim, uBYTE *,sdim,sdim);
  201. extern void write_psgrey(FILE *,dim,dim, uBYTE *,sdim,sdim);
  202. extern void write_epsdith(FILE *,dim,dim, uBYTE *,sdim,sdim);
  203. extern void write_psdith(FILE *,dim,dim, uBYTE *,sdim,sdim);
  204.  
  205. extern FLTPT        PAPER_LEFT,PAPER_BOTTOM,PAPER_WIDTH,PAPER_HEIGHT,PRINTER_XDPI,PRINTER_YDPI,PRINTER_FAK;
  206. extern sINT         PSIZE_SET,DPI_SET,FAK_SET;
  207.  
  208.